cmake_minimum_required(VERSION 3.5)

project(Qt5DpdkDemo VERSION 0.1 LANGUAGES C CXX)
# 关闭C++编译器的某些无必要的警告
set(CMAKE_VERBOSE_MAKEFILE ON)
add_compile_options("-Wno-unused-variable")
add_compile_options("-Wno-deprecated-declarations")

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# Linux工具PkgConfig
find_package(PkgConfig REQUIRED)
# cmake利用Linux工具查找系统中安装的DPDK开发库
pkg_check_modules(dpdk REQUIRED IMPORTED_TARGET libdpdk)



add_executable(main
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
    # -----------------
    l2fwd_demo_thread.h
    l2fwd_demo_thread.c
)
# 让编译器链接DPDK的librte_xxx.so动态库
target_link_libraries(main PRIVATE PkgConfig::dpdk)
# Qt 的动态库
target_link_libraries(main PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)


set_target_properties(main PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)
install(TARGETS main
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
